<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s"  uri="/struts-tags"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=cn-gb">
		<link href="css/style.css" rel="stylesheet" type="text/css">
		  <s:head theme="xhtml"/>
  		  <sx:head parseContent="true"/>

		<title>添加 入库退货单明细</title>

		<script type="text/javascript">
			function buyBackDetailAction() {
				var d = document.forms[0];
				d.action = "addNewBuyBackDetail";
				d.submit();
			}

			function autoCalc() {
				var f = document.forms[0];
				str = f.price.value;
				if ( isNaN(str) ) {
					f.price.value = 0;
					f.money.value = 0;
					f.price.focus();
					alert( "输入错误，请在单价栏 输入数值" );
					return;
				}
				str = f.amount.value;
				if ( isNaN(str) ) {
					f.amount.value = 0;
					f.money.value = 0;
					f.amount.focus();
					alert( "输入错误，请在数量栏 输入数值" );
					return;
				}

				f.money.value = f.price.value * f.amount.value;
			}
		</script>

		<style type="text/css">
		.errorMessage {
			font-size: 12px;
			color: red;
		}
		</style>
	</head>

	<body>
		<center>
			<h2>
				添加 入库退货单明细
			</h2>
		</center>
		<center>
			<font color="red"> ${requestScope.error}</font> <!-- 取不到 -->
			<%  String errInfo = request.getParameter( "error" ) ; // 实现方式改进了，现在 取到的不是 "dup"了 。先留在这里
				if ( "dup".equals( errInfo ) ) { %>
					<font color="red">增加明细信息失败，请检查商品信息是否重复</font>
			<% } %>

			<font color="red"><s:property value="%{errMsg}" /></font>  <!-- 取不到 -->

			<%  String sErrMsg = request.getParameter( "error" ) ;
				if ( sErrMsg == null ) sErrMsg = "";
				sErrMsg = new String( sErrMsg.getBytes("ISO-8859-1"), "UTF-8" );
			%>
			<font color="red"><%= sErrMsg %></font>

			<s:form method="post">

				<s:hidden name="buyBackDetail.buyBackId"  value="%{buyBackMain.id}"/>

				<table>
					<tr>
						<td>
							<s:select id="goodList" name="buyBackDetail.goodId" label="商品"
								  list="%{#request.currSuppAllGood}"
								  listKey="id" listValue="shortName" />
						</td>
					</tr>
					<tr>
						<td>
							<s:textfield label="单价" name="buyBackDetail.price"  id="price"
							   onblur = "autoCalc()"  />
						</td>
					</tr>
					<tr>
						<td>
							<s:textfield label="数量" name="buyBackDetail.amount" id="amount" onblur = "autoCalc()" />
						</td>
					</tr>
					<tr>
						<td>
							<s:textfield label="金额" name="buyBackDetail.money"  id="money" readonly="true" />
						</td>
					</tr>
					<tr align="center">
						<td colspan="2">
							<input type="button" value="保存" name="Save" onclick="buyBackDetailAction();" />
							<input type="reset"  value="重置" name="Reset" />
							<input type="button" value="返回" name="Back" onclick="history.go(-1);" />
						</td>
					</tr>
				</table>
			</s:form>
		</center>
	</body>
</html>